package com.cy.pj.sys.web.controller;


import com.cy.pj.common.pojo.JsonResult;
import com.cy.pj.common.util.PageUtil;
import com.cy.pj.sys.pojo.SysLog;
import com.cy.pj.sys.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/SysLog")
public class SysLogController {

    @Autowired
    private SysLogService sysLogService;

    //不用写添加日志，因为日志是用户行为记录，不能单独添加日志

    @DeleteMapping("/{ids}")
    public JsonResult dodeleteLogs(@PathVariable(name = "ids") Integer...ids){
        sysLogService.deleteLogs(ids);
        return new JsonResult("delete ok!!!");
    }

    @GetMapping("/{id}")
    public JsonResult dofindById(@PathVariable(name = "id") Integer id){
        SysLog byId = sysLogService.findById(id);
        return new JsonResult(byId);
    }

    @GetMapping
    public JsonResult dofindByIds(SysLog sysLog){
        return new JsonResult(PageUtil.startPage().doSelectPageInfo( ()->sysLogService.findByIds(sysLog)) );

//        return new JsonResult(PageUtil.startPage().doSelectPageInfo(new ISelect() {
//            @Override
//            public void doSelect() {
//                sysLogService.findByIds(sysLog);
//            }
//        }));

//        List<SysLog> byIds = sysLogService.findByIds(sysLog);
//        return new JsonResult(byIds);
    }
}
